/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import system.*;
/**
 *
 * @author tj
 */
class MyMenuBar extends JMenuBar {

    MenuListener menuListener = new MenuListener();
    MovieHandler movies;
    public MyMenuBar(MovieHandler movies, String userName) {
        this.movies=movies;
        JMenu fileMenu = new JMenu("File");
        JMenu movieMenu = new JMenu("Movie");

        //JMenuItem logoutItem = new JMenuItem("Logout "+userName);
        JMenuItem exitItem = new JMenuItem("Exit");
        JMenuItem trailerItem = new JMenuItem("Trailer");
        //JMenuItem rateItem = new JMenuItem("Rate");
        exitItem.addActionListener(menuListener);
        //logoutItem.addActionListener(menuListener);
        trailerItem.addActionListener(menuListener);
        //rateItem.addActionListener(menuListener);

        //fileMenu.add(logoutItem);
        fileMenu.add(exitItem);
        movieMenu.add(trailerItem);
        //movieMenu.add(rateItem);

        add(fileMenu);
        add(movieMenu);


    }

    private class MenuListener implements ActionListener {

        public MenuListener() {
        }

        public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals("Exit")) {
                System.out.println("EXIT");
                System.exit(0);
            }
            if (e.getActionCommand().equals("Trailer")) {
                System.out.println("öppnar youtube");
                movies.getSelectedMovie().searchOnYouTube();
                //System.exit(0);
            }
        }
    }
}
